void Mul(PolyNode* ha, PolyNode* hb, PolyNode*& hc)  //ha和hb相加得到hc
{
	PolyNode* pa = ha->next, * pb, * s, * tc;
	hc = (PolyNode*)malloc(sizeof(PolyNode));
	tc = hc;
	while (pa != NULL)
	{
		pb = hb->next;
		while (pb != NULL)
		{
			s = (PolyNode*)malloc(sizeof(PolyNode));
			s->coef = pa->coef * pb->coef;
			s->exp = pa->exp + pb->exp;
			tc->next = s;
			tc = s;
			pb = pb->next;
		}
		pa = pa->next;
	}
	tc->next = NULL;
}

void Comb(PolyNode*& L) //合并指数相同的项
{
	PolyNode* pre = L->next, * p;
	if (pre == NULL) return;
	p = pre->next;
	while (p != NULL)
	{
		while (p->exp == pre->exp)
		{
			pre->coef += p->coef;
			pre->next = p->next;
			free(p);
			p = pre->next;
		}
		pre = p;
		p = p->next;
	}
}

void DelZero(PolyNode*& L) //删除系数为0的项
{
	PolyNode* pre = L, * p = pre->next;
	while (p != NULL)
	{
		if (p->coef == 0.0)
		{
			pre->next = p->next;
			free(p);
		}
		pre = p;
		p = p->next;
	}
}

Mul(ha, hb, hc);
Sort(hc);
Comb(hc);
DelZero(hc);